<template>
    <div>
        <div class="name center-flex-box">
            <el-tooltip effect="dark" :content="userInfo.nickname" :placement="promptDirection">
                <a @click="goToUserHome(userInfo.id)" class="nickname">{{userInfo.nickname}}</a>
            </el-tooltip>
        </div>
        <div class="avatar center-flex-box">
            <div class="icon">
                <img :src="userInfo.avatar" @click="goToUserHome(userInfo.id)" class="face">
            </div>
        </div>
    </div>
</template>

<script>
    export default {
        name: 'simpleUserInfoRight',
        props: ['userInfo'],
        computed: {
            cssType () {
                return this.type ? this.type : 'default'
            },
            promptDirection () {
                return this.cssType === 'default' ? 'top' : 'bottom'
            }
        },
        methods: {
            goToUserHome (id) {
                this.$router.push(`/user/info/${id}`)
            }
        }
    }
</script>

<style lang="scss" scoped>
    @import '../../../style/scss';

    .name {
        width: 50%;
        height: 100%;
        padding: 0 5%;

        .nickname {
            font-size: 12px;

            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
        }

        a {
            text-decoration: none;
            cursor: pointer;
        }

        a:link {
            color: #216278;
        }

        a:visited {
            color: #216278;
        }

        a:hover {
            color: rgba(255, 151, 60, 0.8);
        }

        a:active {
            color: rgba(255, 86, 25, 0.8);
        }
    }

    .avatar {
        height: 100%;

        .icon {
            width: 50px;
            height: 50px;
            padding: 5px;
            position: relative;
            float: right;

            .face {
                width: 100%;
                height: 100%;
                border-radius: 50% 50%;
                cursor: pointer;
            }
        }
    }
</style>
